import { CHECC_API_BASE_DATA, CHECC_API_CMS, CHECC_API_FAST_DFS } from '@/constants/proxy'
import request from '@/utils/request'
import { ObjectType, ResponseDataPromise } from 'typings/interfaces'
import { Pagination } from '@/components/Records/types'
export interface Params extends ObjectType {
  goodsType?: string
  goodsName?: string
}
// 数据字典
export function dataDictionary(data: any) {
  return request({
    url: CHECC_API_CMS + '/dictItem/codelist',
    method: 'post',
    data,
  })
}

//获取路段数据
export function getRoadSection(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-fixed-section/list',
    method: 'post',
    data,
  })
}
// 文档删除
export function deleteFile(data: any) {
  return request({
    url: CHECC_API_FAST_DFS + '/file',
    method: 'delete',
    params: data,
  })
}
// 文档查询
export function getFile(id: any) {
  return request({
    url: CHECC_API_FAST_DFS + `/file_info/${id}`,
    method: 'get',
  })
}
//边坡防护分页
export function getProtection(data: any, params: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-slope-in/page',
    method: 'post',
    data: data,
    params,
  })
}
// 边坡新增
export function batchProtection(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-slope-in/insert',
    method: 'post',
    data: data,
  })
}
// 边坡删除
export function delProtection(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-slope-in/deleteList`,
    method: 'delete',
    data
  })
}
// 边坡编辑
export function editProtection(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-slope-in/update',
    method: 'put',
    data: data,
  })
}
//边坡防护通过ID查询
export function EditQueryDictionary(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-slope-in/selectById/${data}`,
    method: 'get',
  })
}
// 锁定/解锁
export function lockingProtection(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-slope-in/updateDataLock',
    method: 'get',
    params: data,
  })
}
// 边坡子表查询
export function getSubsideSlope(data: any, id: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-slope-in-construction/page',
    method: 'post',
    data: data,
    params: id,
  })
}
// 边坡子表 更改 保存  删除
export function batchSubsideSlope(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-slope-in-construction',
    method: data.method,
    data: data.data,
  })
}

// 排水设施
export function getFacilities(data: any, id: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-drainage-facility-in/page',
    method: 'post',
    data: data,
    params: id,
  })
}
//  排水设施新增
export function batchFacilities(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-drainage-facility-in/insert',
    method: 'post',
    data: data,
  })
}
// 排水删除
export function delFacilities(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-drainage-facility-in/deleteList`,
    method: 'delete',
    data
  })
}
// 排水编辑
export function editFacilities(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-drainage-facility-in/update',
    method: 'put',
    data: data,
  })
}
// 锁定/解锁
export function lockingFacilities(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-drainage-facility-in/updateDataLock',
    method: 'get',
    params: data,
  })
}
//排水设施通过ID查询
export function EditQueryFacilities(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-drainage-facility-in/selectById/${data}`,
    method: 'get',
  })
}

// 排水设施子表查询
export function getSubFacilities(data: any, id: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-drainage-facility-in-constru/page',
    method: 'post',
    data: data,
    params: id,
  })
}
// 排水设施子表 新增 删除 修改
export function batchSubFacilities(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-drainage-facility-in-constru',
    method: data.method,
    data: data.data,
  })
}

//新路基查询
export function getSubgrades(data: any, id: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-roadbed-in/page',
    method: 'post',
    data: data,
    params: id,
  })
}
//路基新增
export function batchSubgrades(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-roadbed-in/insert',
    method: 'post',
    data: data,
  })
}
// 路基删除
export function delSubgrades(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-roadbed-in/deleteList`,
    method: 'delete',
    data
  })
}
// 路基编辑
export function editSubgrades(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-roadbed-in/update',
    method: 'put',
    data: data,
  })
}
//通过ID查询数据
export function EditQuerySubgrades(id: any) {
  return request({
    url: CHECC_API_BASE_DATA + `/bd-roadbed-in/selectById/${id}`,
    method: 'get',
  })
}
// 锁定/解锁
export function lockingSubgrades(data: any) {
  return request({
    url: CHECC_API_BASE_DATA + '/bd-roadbed-in/updateDataLock',
    method: 'get',
    params: data,
  })
}


// 路基概览
export const ISubgradeOverview = (
  pagination: Omit<Pagination, 'total'>,
  data: Params
): ResponseDataPromise<ObjectType> =>
  request({
    url: CHECC_API_BASE_DATA + '/bd-roadbed-in/overview',
    method: 'post',
    data,
    params: Object.assign(pagination, data),
  })